package com.yundasys.lab02springbootstudy.future;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;

import java.util.Random;
import java.util.concurrent.CompletableFuture;

/**
 * @PACKAGE_NAME: com.yundasys.lab02springbootstudy.future
 * @NAME: AsyncService
 * @USER: jiangta
 * @DATE: 2022/10/13
 * @TIME: 9:39 上午
 * @PROJECT_NAME: springboot-labs
 */
@Slf4j
public class AsyncService {

    @Async("executorBeanName")
    public CompletableFuture<String> doSomeThingAsync(String strList) {
        log.info("doSomeThingAsync");

        // do some thing ...
        try {
            Thread.sleep(new Random().nextLong());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return CompletableFuture.completedFuture(strList);
    }
}
